# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=paperwork
pkgver=2.2.1
pkgrel=2
pkgdesc='Personal document manager for GNOME to manage scanned documents and PDFs'
arch=('any')
url='https://openpaper.work/'
license=('GPL3')
depends=('gtk3' 'libhandy' 'libinsane' 'libnotify' 'poppler-glib' 'python-cairo' 'python-dateutil'
         'python-distro' 'python-fabulous' 'python-getkey' 'python-gobject' 'python-levenshtein'
         'python-pillowfight' 'python-pycountry' 'python-pydbus' 'python-pyocr' 'python-setuptools'
         'python-whoosh' 'python-pyxdg' 'python-psutil' 'python-scikit-learn')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools-scm' 'python-wheel')
noextract=("$pkgname-${_commit:0:8}-data.tar.gz")
_commit=0bea405421b4e85f1480412c9c683a5cbc94b1f2
source=("git+https://gitlab.gnome.org/World/OpenPaperwork/paperwork.git#commit=$_commit")
#        "$pkgname-${_commit:0:8}-data.tar.gz::https://download.openpaper.work/data/paperwork/master_${_commit:0:8}/data.tar.gz")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

build() {
  cd $pkgname
#  tar -xvzf ../$pkgname-${_commit:0:8}-data.tar.gz
  make l10n_compile

  for dir in openpaperwork-{core,gtk} paperwork-{backend,shell,gtk}; do
    pushd $dir
    python -m build --wheel --no-isolation
    popd
  done
}

package() {
  cd $pkgname
  for dir in openpaperwork-{core,gtk} paperwork-{backend,shell,gtk}; do
    pushd $dir
    python -m installer --destdir="$pkgdir" dist/*.whl
    popd
  done

  PYTHONPATH="$pkgdir"`python -c 'import site; print(site.getsitepackages()[0])'` \
    "$pkgdir"/usr/bin/paperwork-gtk install \
      --icon_base_dir="$pkgdir/usr/share/icons" \
      --data_base_dir="$pkgdir/usr/share"
}
